import request from '@/axios';

export const upload = (file, isPublic, progressFuc) => {
  const form = new FormData();
  form.append("file", file);
  form.append("isPublic", isPublic);
  return request({
    headers:{'Content-Type':'multipart/form-data'},
    url: '/api/blade-resource/file/upload',
    method: 'post',
    data: form,
    onUploadProgress:function(progressEvent){
      if (progressFuc) {
        if (progressEvent.total > 0) {
          progressEvent.percent = progressEvent.loaded / progressEvent.total * 100;
        }
        progressFuc(progressEvent)
      }
    }
  })
}
